﻿using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class Data_Train_Schedule : Data
    {
        #region[Train_Schedule_Insert]
        public void Train_Schedule_Insert(Train_Schedule data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Train_Schedule_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Schedule_ID",data.Schedule_ID);
                cmd.Parameters.Add("@Train_No",data.Train_No);

                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[Train_Schedule_Update]
        public void Train_Schedule_Update(Train_Schedule data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Train_Schedule_Update_ByID", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Schedule_ID", data.Schedule_ID);
                cmd.Parameters.Add("@Train_No", data.Train_No);

                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[Train_Schedule_GetAll]
        public DataTable Train_Schedule_GetAll()
        {
            using (SqlCommand cmd = new SqlCommand("sp_Train_Schedule_GetAll", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                return dt;
            }
        }
        #endregion
    }
}
